package com.xiaoxu.scala_base.code

/**
  * scala Class
  * author: zhangXu
  * createTime: 2018-12-09 15:32
  **/
object ScalaClass {
  def main(args: Array[String]): Unit = {
    val people  = new People()
    //people.age=15;

    println(people.age)

    people.name = "laoWang"

    println(people.name)
    println(people.eat())
    people.read("褚世健传")
  }
}

class People {

  //var 变量，默认有get和set方法
  // _ 占位符
   var name: String = _;
  //val 常量，默认只有set方法
  val age: Int = 18;

  private  val sex:String = "男";

  //方法 最后一行是返回值
  def eat(): String = {
    name + "eating..."
  }

  def read(book: String): Unit = {
    println(name + "读" + book +sex)
  }

}
